//
//  HomeView.swift
//  MyCloset
//
//  Created by 牟好好 on 2024/10/27.
//

import SwiftUI

struct HomeView: View {
    @State private var selectedTab: String = "house"
    @State private var showBottomBar = true
    
    var body: some View {
        NavigationView {
            ZStack {
                VStack {
                    if selectedTab == "house" {
                        MineView()
                    } else if selectedTab == "camera" {
                        CaptureView()
                    } else {
                        SettingView()
                    }
                }
                
                if showBottomBar {
                    VStack {
                        Spacer()
                        BottomBarView(selectedTab: $selectedTab)
                    }
                }
            }
            .onAppear {
                showBottomBar = true
            }
            .onDisappear {
                showBottomBar = false
            }
        }
    }
}

#Preview {
    NavigationView {
        HomeView()
            .environmentObject(CaptureViewModel())
            .environmentObject(ClothStylesViewModel())
    }
}

#Preview {
    NavigationView {
        HomeView()
            .preferredColorScheme(.dark)
            .environmentObject(CaptureViewModel())
            .environmentObject(ClothStylesViewModel())
    }
}
